package imnu.work.imnu0714_work02.work_1;

import java.util.Arrays;

/**
 * @author: lys
 * @类名: Student
 * @Title:
 * @date: 2020/7/14
 **/
public class Student {
    private int stuId;
    private String stuName;
    private int stuGrade;

    public Student(){
    }

    public Student(int stuId, String stuName, int stuGrade){
        this.stuId = stuId;
        this.stuName = stuName;
        this.stuGrade = stuGrade;
    }

    public int getStuId() {
        return stuId;
    }

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public int getStuGrade() {
        return stuGrade;
    }

    public void setStuGrade(int stuGrade) {
        this.stuGrade = stuGrade;
    }

    public static void sortGrade(Student[] s){
        int len = s.length;
        int[] a = new int[len];
        for (int i=0;i<len;i++){
            a[i] = s[i].getStuGrade();
        }
        Arrays.sort(a);
        for (int i = a.length-1; i >= 0; i--) {
            for (int j = 0; j < s.length; j++) {
                if (s[j].getStuGrade()==a[i]){
                    System.out.println(s[j]);
                }
            }
        }
//        for(int i=0;i<s.length-1;i++){
//            for(int j=0;j<s.length-1-i;j++){
//                if(s[j].stuGrade<s[j+1].stuGrade){
//                    Student t = s[j];
//                    s[j] = s[j+1];
//                    s[j+1] = t;
//                }
//            }
//        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuId=" + stuId +
                ", stuName='" + stuName + '\'' +
                ", stuGrade=" + stuGrade +
                '}';
    }
}
